package edu.chl.dat255.bluebanana.utils;

public class StringUtil {
	
	public static int getOnlyNumerics(String string) {
	    if (string == null) {
	        return -1;
	    } else if (string.contains("min")) {
	    	string = string.substring(0, string.indexOf("m") - 1);
	    	string.trim();
			int i = Integer.valueOf(string).intValue();
			string = i * 60 + "";
	    }

	    StringBuffer stringBuffer = new StringBuffer();
	    char character;
	    
	    for (int i = 0; i < string.length() ; i++) {
	        character = string.charAt(i);
	        
	        if (Character.isDigit(character)) {
	            stringBuffer.append(character);
	        }
	    }
	    return Integer.parseInt(stringBuffer.toString());
	}
}
